package com.heima.fallback;

import com.heima.feign.ArticleFeignClient;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.pojos.Article;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmNews;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author chenshan
 */
@Component
public class ArticleClientFallback implements FallbackFactory<ArticleFeignClient> {
    @Override
    public ArticleFeignClient create(Throwable throwable) {
        return new ArticleFeignClient() {
            @Override
            public ResponseResult saveArticle(ArticleDto articleDto) {
                return ResponseResult.errorResult(5000, "远程调用失败");
            }

            @Override
            public ResponseResult articleConfigDownOrUp(WmNews news) {
                return ResponseResult.errorResult(5000, "远程调用失败");
            }

            @Override
            public ResponseResult findOneById(Long articleId) {
                return ResponseResult.errorResult(5000, "远程调用失败");
            }

            @Override
            public ResponseResult findAll() {
                return ResponseResult.errorResult(5000, "远程调用失败");
            }

            @Override
            public ResponseResult findArticleByChannelId(Integer channelId) {
                return ResponseResult.errorResult(5000, "远程调用失败");
            }

            @Override
            public boolean updateArticle(Article article) {
                return false;
            }

            @Override
            public Article findArticleById(Long id) {
                return null;
            }

            @Override
            public ResponseResult selectFiveDaysArticle() {
                return ResponseResult.errorResult(5000, "远程调用失败");
            }

        };
    }
}
